﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PrimaryAlgorithm.IsPalindrome
{
    class MainProject
    {
        static void Main(string[] args)
        {
            string a = "0P";

            Console.WriteLine(IsPalindrome(a));
            Console.ReadKey();
        }
        public static bool IsPalindrome(string s)
        {
            List<char> listChar = new List<char>();
            foreach (var item in s)
            {
                if (65 <= item && item <= 90 || 97<=item && item<=122 || 48<=item && item<=57)
                {
                    listChar.Add(char.ToLower(item));
                }
            }
            //双指针
            int last = 0, next = listChar.Count-1;
            while (last<=next)
            {
                if (listChar[last] != listChar[next])
                {
                    return false;
                }
                last++;
                next--;
            }
            return true;
        }
    }
}
